Skip to content

ember ts:precomile throws if a file in node_modules has a TS error #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexdiliberto opened this issue Dec 22, 2019 · 2 comments
Closed
Labels

Comments

@alexdiliberto
Copy link

alexdiliberto commented Dec 22, 2019

Please paste the output of ember -v here

$ ember -v
ember-cli: 3.14.0
node: 12.13.1
os: darwin x64

Please paste the output of tsc -v here

$ tsc -v
Version 3.7.3

Please paste the version of ember-cli-typescript and ember-cli-typescript-blueprints here

$ yarn list --pattern 'ember-cli-typescript'
yarn list v1.21.1
├─ @glimmer/component@1.0.0
│  └─ ember-cli-typescript@3.0.0
├─ ember-app-scheduler@1.0.8
│  └─ ember-cli-typescript@2.0.2
├─ ember-cli-typescript-blueprints@3.0.0
├─ ember-cli-typescript@3.1.2
└─ ember-load-initializers@2.1.1
   └─ ember-cli-typescript@2.0.2
✨  Done in 0.84s.

Please paste your tsconfig.json and tslint.json or eslint.json (if applicable) below

My tsconfig.json

{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictNullChecks": true,
"strictPropertyInitialization": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noEmitOnError": false,
"noEmit": true,
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": ".",
"module": "es6",
"experimentalDecorators": true,
"paths": {
"dummy/tests/": [
"tests/
"
],
"dummy/": [
"tests/dummy/app/
",
"app/"
],
"ember-transformicons": [
"addon"
],
"ember-transformicons/
": [
"addon/"
],
"ember-transformicons/test-support": [
"addon-test-support"
],
"ember-transformicons/test-support/
": [
"addon-test-support/"
],
"
": [
"types/"
]
}
},
"include": [
"app/**/
",
"addon//*",
"tests/
/",
"types/**/
",
"test-support//*",
"addon-test-support/
/*"
]
}

What are instructions we can follow to reproduce the issue?

cd my-ember-addon
npm publish

OR

cd my-ember-addon
ember ts:precompile
Reproduction Case

Adding onto #973 and #984 - I'm still experiencing ember ts:precompile errors unless I add --skipLibCheck here

should tsc fail the compilation step as far as ember is concerned if some node_modules file has a TS error or am I missing something here?

$ ember ts:precompile

node_modules/@types/ember/index.d.ts:142:29 - error TS2507: Type 'typeof import("@ember/component")' is not a constructor function type.

142     class Component extends EmberComponent {}
                                ~~~~~~~~~~~~~~

node_modules/@types/ember__component/checkbox.d.ts:7:39 - error TS2507: Type 'typeof import("@ember/component")' is not a constructor function type.

7 export default class Checkbox extends Component {}
                                        ~~~~~~~~~

node_modules/@types/ember__component/text-area.d.ts:8:49 - error TS2339: Property 'extend' does not exist on type 'typeof import("@ember/component")'.

8 export default class TextArea extends Component.extend(TextSupport) {}
                                                  ~~~~~~

node_modules/@types/ember__component/text-field.d.ts:7:50 - error TS2339: Property 'extend' does not exist on type 'typeof import("@ember/component")'.

7 export default class TextField extends Component.extend(TextSupport) {
                                                   ~~~~~~

node_modules/@types/ember__routing/link-component.d.ts:8:44 - error TS2507: Type 'typeof import("@ember/component")' is not a constructor function type.

8 export default class LinkComponent extends Component {
                                             ~~~~~~~~~

types/ember-cli-htmlbars/index.d.ts:1:70 - error TS2304: Cannot find name 'TemplateFactory'.

1 export function hbs(template: TemplateStringsArray, ...args: any[]): TemplateFactory;
                                                                       ~~~~~~~~~~~~~~~


Found 6 errors.


Command failed with exit code 2: tsc --allowJs false --noEmit false --rootDir /Users/alexdiliberto/Repos/ember-transformicons --isolatedModules false --declaration --declarationDir /var/folders/m0/tbgpth7x3fxbrbg8xk25t_7r0000gn/T/e-c-ts-precompile-22906 --emitDeclarationOnly --pretty true


Stack Trace and Error Report: /var/folders/m0/tbgpth7x3fxbrbg8xk25t_7r0000gn/T/error.dump.ff2d97b26e7249b4763487bfe83ea5e0.log

Now about that bug. What did you expect to see?

I expected ember ts:precompile to not fail if a node_modules file had a TS error because I don't have control over all node_modules files

What happened instead?

ember ts:precompile throws unless I add --skipLibCheck here

alexdiliberto added a commit to alexdiliberto/ember-transformicons that referenced this issue Dec 22, 2019
this is a workaround until I hear back about the following issue:
typed-ember/ember-cli-typescript#1029
@chriskrycho
Copy link
Member

Hey @alexdiliberto, sorry for the delay—I just saw this as I was triaging GH notifications!

I think this behavior is actually as expected: this is just how TS works, and as you discovered TS itself provides a hook to let you opt out of checking library code upstream. The reason TS does this (and the reason we definitely want to continue doing it) is that if you don't check your dependencies, you're not actually using their types at all—so you can't tell if your own code is using those dependencies' types correctly. You'd only get info from the types inside your own app. 😬

@alexdiliberto
Copy link
Author

Thank you for the update, Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants