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

fix: error TS2339: Property 'VISUALIZE' does not exist on type 'typeof TargetLanguage' #1293

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const project = new typescript.TypeScriptProject({
compilerOptions: {
// @see https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
lib: ['es2020', 'es2021.WeakRef'],
target: 'ES2020',
target: 'es2020',
moduleResolution: javascript.TypeScriptModuleResolution.NODE_NEXT,
module: 'nodenext',
esModuleInterop: false,
Expand Down Expand Up @@ -140,6 +140,12 @@ const project = new typescript.TypeScriptProject({
],
});

// Double check emitted type declarations are valid
// This is needed because we are ignoring some declarations, which may produce invalid type declarations if not carefully crafted
project.compileTask.exec(
`tsc lib/index.d.ts --noEmit --skipLibCheck -t ${project.tsconfig?.compilerOptions?.target} -m ${project.tsconfig?.compilerOptions?.module}`,
);

// PR validation should run on merge group, too...
(project.tryFindFile('.github/workflows/pull-request-lint.yml')! as YamlFile).patch(
JsonPatch.add('/on/merge_group', {}),
Expand Down
12 changes: 7 additions & 5 deletions src/languages/target-language.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import * as assert from 'node:assert';

export enum TargetLanguage {
/** @internal an alias of PYTHON to make intent clear when language is irrelevant */
VISUALIZE = 'python',
PYTHON = 'python',
CSHARP = 'csharp',
JAVA = 'java',
GO = 'go',
/** @internal an alias of PYTHON to make intent clear when language is irrelevant, must be last */
VISUALIZE = 'python',
}

const VALID_TARGET_LANGUAGES = new Set(Object.values(TargetLanguage));

/** @internal an alias of PYTHON to make intent clear when language is irrelevant */
export function targetName(language: TargetLanguage.VISUALIZE): 'python';
export function targetName(language: TargetLanguage): 'python' | 'dotnet' | 'java' | 'go';
export function targetName(language: TargetLanguage.PYTHON): 'python';
export function targetName(language: TargetLanguage.CSHARP): 'dotnet';
export function targetName(language: TargetLanguage.JAVA): 'java';
export function targetName(language: TargetLanguage.GO): 'go';
export function targetName(language: TargetLanguage): 'python' | 'dotnet' | 'java' | 'go';
/** @internal an alias of PYTHON to make intent clear when language is irrelevant, must be last override */
export function targetName(language: TargetLanguage.VISUALIZE): 'python';

/**
* @param language a possible value for `TargetLanguage`.
*
* @returns the name of the target configuration block for the given language.
*/
export function targetName(language: TargetLanguage): 'python' | 'dotnet' | 'java' | 'go';
export function targetName(language: TargetLanguage): 'python' | 'dotnet' | 'java' | 'go' {
// The TypeScript compiler should guarantee the below `switch` statement covers all possible
// values of the TargetLanguage enum, but we add an assert here for clarity of intent.
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.dev.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading