Skip to content
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

Enable "strict" mode for runtime code. #3426

Closed
wants to merge 2 commits into from

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Dec 1, 2019

We should be able to do this now.

Fixes #3324

@kitsonk
Copy link
Contributor Author

kitsonk commented Jan 20, 2020

Too many changes, will take another stab at this at some point in the future.

@kitsonk kitsonk closed this Jan 20, 2020
@Ciantic
Copy link

Ciantic commented Feb 5, 2020

What do you mean by too many changes? I hope this makes it before 1.0, because that's when the libraries will start to gather speed.

@maxmellen
Copy link
Contributor

@kitsonk Would you be open to contributions on this?

@kitsonk
Copy link
Contributor Author

kitsonk commented Feb 5, 2020

Too many changes upstream, making it difficult to land the PR.

Yeah, @maxmellen, if you wanted to try.

@maxmellen
Copy link
Contributor

Great! Having a go at it.

I noticed these compiler options moved to compiler_host.ts where there are now multiple sets of compiler options:

/** Options that need to be used when generating a bundle (either trusted or
* runtime). */
export const defaultBundlerOptions: ts.CompilerOptions = {
inlineSourceMap: false,
module: ts.ModuleKind.AMD,
outDir: undefined,
outFile: `${OUT_DIR}/bundle.js`,
// disabled until we have effective way to modify source maps
sourceMap: false
};
/** Default options used by the compiler Host when compiling. */
export const defaultCompileOptions: ts.CompilerOptions = {
allowJs: true,
allowNonTsExtensions: true,
// TODO(#3324) Enable strict mode for user code.
// strict: true,
checkJs: false,
esModuleInterop: true,
module: ts.ModuleKind.ESNext,
outDir: OUT_DIR,
resolveJsonModule: true,
sourceMap: true,
stripComments: true,
target: ts.ScriptTarget.ESNext,
jsx: ts.JsxEmit.React
};
/** Options that need to be used when doing a runtime (non bundled) compilation */
export const defaultRuntimeCompileOptions: ts.CompilerOptions = {
outDir: undefined
};
/** Default options used when doing a transpile only. */
export const defaultTranspileOptions: ts.CompilerOptions = {
esModuleInterop: true,
module: ts.ModuleKind.ESNext,
sourceMap: true,
scriptComments: true,
target: ts.ScriptTarget.ESNext
};

I was wondering if strict mode should also be enabled in these other options, notably the defaultTranspileOptions.

@kitsonk What do you think?

@maxmellen
Copy link
Contributor

@kitsonk I've opened a PR here: #3899

@kitsonk
Copy link
Contributor Author

kitsonk commented Feb 6, 2020

Transpile does no type checking, so strict mode makes no sense there.

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

Successfully merging this pull request may close these issues.

User libraries should be strict by default if written in TypeScript
3 participants