-
Notifications
You must be signed in to change notification settings - Fork 712
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
Strict null checks! #845
Strict null checks! #845
Changes from 7 commits
cc401fa
752d8cf
93958a5
8f90d12
1735d4d
820077a
c109e8b
589f15a
eeccb6b
f7d5683
f0166cf
1108878
b371fd4
7247605
ee162c9
daab024
5759cb5
20c90c7
179f5af
9bd8836
e1bb10c
fbe3a5a
fc192ce
e110441
4dcf9b1
4bf87f6
bc469d8
cd840fb
5517705
4d4ff46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
.baseDir.js | ||
.baseDir.ts | ||
yarn.lock | ||
yarn-error.log | ||
|
||
/src/typings/typescript/typescript.js | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "0.1.0", | ||
"command": "tsc", | ||
"isShellCommand": true, | ||
"args": ["-w", "-p", "."], | ||
"showOutput": "silent", | ||
"isWatching": true, | ||
"problemMatcher": "$tsc-watch" | ||
} | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"identifier": "build", | ||
"type": "grunt", | ||
"task": "default", | ||
"problemMatcher": [ | ||
"$tsc" | ||
] | ||
}, | ||
{ | ||
"identifier": "build_and_test", | ||
"type": "grunt", | ||
"task": "build_and_test", | ||
"problemMatcher": [ | ||
"$tsc" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import { Serializer } from './serialization'; | |
import { ProjectReflection } from './models/index'; | ||
import { Logger, ConsoleLogger, CallbackLogger, PluginHost, writeFile } from './utils/index'; | ||
|
||
import { AbstractComponent, ChildableComponent, Component, Option } from './utils/component'; | ||
import { AbstractComponent, ChildableComponent, Component, Option, DUMMY_APPLICATION_OWNER } from './utils/component'; | ||
import { Options, OptionsReadMode, OptionsReadResult } from './utils/options/index'; | ||
import { ParameterType } from './utils/options/declaration'; | ||
|
||
|
@@ -67,21 +67,21 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
defaultValue: 'console', | ||
type: ParameterType.Mixed | ||
}) | ||
loggerType: string|Function; | ||
readonly loggerType!: string|Function; | ||
|
||
@Option({ | ||
name: 'ignoreCompilerErrors', | ||
help: 'Should TypeDoc generate documentation pages even after the compiler has returned errors?', | ||
type: ParameterType.Boolean | ||
}) | ||
ignoreCompilerErrors: boolean; | ||
readonly ignoreCompilerErrors!: boolean; | ||
|
||
@Option({ | ||
name: 'exclude', | ||
help: 'Define patterns for excluded files when specifying paths.', | ||
type: ParameterType.Array | ||
}) | ||
exclude: Array<string>; | ||
readonly exclude!: Array<string>; | ||
|
||
/** | ||
* The version number of TypeDoc. | ||
|
@@ -94,7 +94,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
* @param options An object containing the options that should be used. | ||
*/ | ||
constructor(options?: Object) { | ||
super(null); | ||
super(DUMMY_APPLICATION_OWNER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why wouldn't we want the owner to be nullable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Searching for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would setting the owner to itself be an alternative to using a symbol and needing to complicate the type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Typescript allowed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I'd like to double back on this, possibly at a later time to find a cleaner solution. For now it works. |
||
|
||
this.logger = new ConsoleLogger(); | ||
this.converter = this.addComponent<Converter>('converter', Converter); | ||
|
@@ -153,9 +153,9 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
* Run the converter for the given set of files and return the generated reflections. | ||
* | ||
* @param src A list of source that should be compiled and converted. | ||
* @returns An instance of ProjectReflection on success, NULL otherwise. | ||
* @returns An instance of ProjectReflection on success, undefined otherwise. | ||
*/ | ||
public convert(src: string[]): ProjectReflection { | ||
public convert(src: string[]): ProjectReflection | undefined { | ||
this.logger.writeln('Using TypeScript %s from %s', this.getTypeScriptVersion(), this.getTypeScriptPath()); | ||
|
||
const result = this.converter.convert(src); | ||
|
@@ -165,7 +165,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
this.logger.resetErrors(); | ||
return result.project; | ||
} else { | ||
return null; | ||
return; | ||
} | ||
} else { | ||
return result.project; | ||
|
@@ -188,7 +188,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
* @param out The path the documentation should be written to. | ||
* @returns TRUE if the documentation could be generated successfully, otherwise FALSE. | ||
*/ | ||
public generateDocs(input: any, out: string): boolean { | ||
public generateDocs(input: ProjectReflection | string[], out: string): boolean { | ||
const project = input instanceof ProjectReflection ? input : this.convert(input); | ||
if (!project) { | ||
return false; | ||
|
@@ -246,7 +246,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone | |
* @param inputFiles The list of files that should be expanded. | ||
* @returns The list of input files with expanded directories. | ||
*/ | ||
public expandInputFiles(inputFiles?: string[]): string[] { | ||
public expandInputFiles(inputFiles: string[] = []): string[] { | ||
let files: string[] = []; | ||
const exclude: Array<IMinimatch> = this.exclude ? this.exclude.map(pattern => new Minimatch(pattern, {dot: true})) : []; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these marked readonly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe my thought process was that they should only be set by option providers, not manually, it would be fine to remove the readonly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove readonly to avoid unnecessary changes for anyone who may be touching the javascript apis.