Skip to content

Instantly share code, notes, and snippets.

@Bnaya
Created October 21, 2020 12:49
Show Gist options
  • Save Bnaya/ccb802d892508f3f4ebd81e3350eea05 to your computer and use it in GitHub Desktop.
Save Bnaya/ccb802d892508f3f4ebd81e3350eea05 to your computer and use it in GitHub Desktop.

commonjs re-export of js + deceleration emit = crash!

run yarn tsc4p1 = Crash!!

run yarn tsc4p0 = "private name error is expected"

/**
* @param {string} a
*/
function bar(a) {
return a + a;
}
class SomeClass {
a() {
return 1;
}
}
module.exports = {
bar,
SomeClass
}
const { SomeClass } = require('./lib');
module.exports = {
SomeClass,
}
{
"name": "ya-emit-types-from-js-issue",
"version": "1.0.0",
"author": "Bnaya Peretz",
"license": "MIT",
"private": "true",
"scripts": {
"tsc4p0": "npx -p [email protected] tsc",
"tsc4p1": "npx -p [email protected] tsc"
}
}
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"allowJs": true,
"checkJs": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./",
"composite": true,
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo",
"isolatedModules": true,
"strict": true,
"types": [],
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["main.js", "lib.js"],
"exclude": ["dist"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment