Skip to content

Commit

Permalink
fix: fix #2011 (#2013)
Browse files Browse the repository at this point in the history
Turn on `exactOptionalPropertyTypes` for types.
  • Loading branch information
Jason3S authored Nov 24, 2021
1 parent 663cc99 commit 15abecb
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 9 deletions.
8 changes: 6 additions & 2 deletions packages/cspell-glob/src/GlobMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { PathInterface, GlobMatch, GlobPattern, GlobPatternWithRoot } from './Gl

// cspell:ignore fname

export type GlobMatchOptions = Partial<NormalizedGlobMatchOptions>;
type Optional<T> = {
[P in keyof T]?: T[P] | undefined;
};

export type GlobMatchOptions = Optional<NormalizedGlobMatchOptions>;

export type MatcherMode = 'exclude' | 'include';

Expand Down Expand Up @@ -59,7 +63,7 @@ interface NormalizedGlobMatchOptions {
*
* @default false
*/
nobrace?: boolean; // cspell:ignore nobrace
nobrace?: boolean | undefined; // cspell:ignore nobrace
}

export class GlobMatcher {
Expand Down
6 changes: 3 additions & 3 deletions packages/cspell-glob/src/GlobMatcherTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export interface GlobPatternWithOptionalRoot {
* The root from which the glob pattern is relative.
* @default: options.root
*/
root?: string;
root?: string | undefined;
/**
* Optional value useful for tracing which file a glob pattern was defined in.
*/
source?: string;
source?: string | undefined;
/**
* Optional line number in the source
*/
line?: number;
line?: number | undefined;
}

export interface GlobPatternWithRoot extends GlobPatternWithOptionalRoot {
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-glob/src/globHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export function fileOrGlobToGlob(
const pathToGlob = path.sep === '\\' ? (p: string) => p.replace(/\\/g, '/') : (p: string) => p;

if (typeof fileOrGlob !== 'string') {
return { root, ...fileOrGlob };
const useRoot = fileOrGlob.root ?? root;
return { ...fileOrGlob, root: useRoot };
}

if (doesRootContainPath(root, fileOrGlob, path) || relRegExp.test(fileOrGlob)) {
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-grammar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"outDir": "dist"
},
"include": [
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"strictFunctionTypes": false,
"outDir": "dist"
},
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"outDir": "dist"
},
"include": [
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-trie-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"outDir": "dist"
},
"include": [
Expand Down
6 changes: 3 additions & 3 deletions packages/cspell-types/src/CSpellSettingsDef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,11 @@ interface BaseSource {
/** name of source */
name: string;
/** filename if this came from a file. */
filename?: string;
filename?: string | undefined;
/** The two settings that were merged to */
sources?: [CSpellSettings] | [CSpellSettings, CSpellSettings];
sources?: [CSpellSettings] | [CSpellSettings, CSpellSettings] | undefined;
/** The configuration read. */
fileSource?: CSpellSettings;
fileSource?: CSpellSettings | undefined;
}

/**
Expand Down
1 change: 1 addition & 0 deletions packages/cspell/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"outDir": "dist"
},
"include": [
Expand Down
1 change: 1 addition & 0 deletions packages/hunspell-reader/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"noImplicitAny": false,
"outDir": "dist"
},
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "node",
"newLine": "LF",
"noImplicitAny": true,
Expand Down

0 comments on commit 15abecb

Please sign in to comment.