profile
viewpoint
Klaus Meinhardt ajafff Germany Building awesomeness

ajafff/tsutils 220

utility functions for working with typescript's AST

ajafff/tslint-consistent-codestyle 192

Collection of awesome rules to extend TSLint

ajafff/ts-transform-readonly-array 4

Convert 'readonly T[]' to 'ReadonlyArray<T>' in declaration emit

ajafff/normalize-glob 1

Normalize a glob pattern by expanding braces, making it absolute and resolving parent directories '..'

ajafff/ts-transform-const-enum 1

TypeScript transformer to convert const enums to regular enums in declaration files

ajafff/arrify 0

Convert a value to an array

ajafff/ava 0

:rocket: Futuristic JavaScript test runner

ajafff/babel 0

🐠 Babel is a compiler for writing next generation JavaScript.

ajafff/DefinitelyTyped 0

The repository for high quality TypeScript type definitions.

ajafff/dependency-cruiser 0

Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.

issue commentfimbullinter/wotan

`no-misused-generics`: missing error for function value

This is kinda working as intended. You could use the type parameter within the function body to ensure type safety or infer the return type:

function a<T>(param: T) {
  return param; // type parameter used in inferred return type
}

function b<T extends string>(param: Map<string, T>) {
  const v = param.get('foo')!;
  param.set('bar', v); // ok
  param.set('bar', 'v'); // should be an error, replacing the type parameter with its constraint makes this pass type checking
}

If you have a good idea how to handle such cases, especially the second case, I'm happy to change the rule.

OliverJAsh

comment created time in 3 months

issue commentmicrosoft/TypeScript

wish: add a warning for Map misuses

noImplictAny?

nahuel

comment created time in 3 months

Pull request review commentmicrosoft/TypeScript

Error on immediate casts of literals to incompatible literal types

 namespace ts {                     checkTypeComparableTo(exprType, targetType, errNode,
                         Diagnostics.Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first);
                 }
+                else if (targetType.flags & TypeFlags.StringLiteral && isStringLiteral(expression) && expression.text !== (targetType as StringLiteralType).value) {

few questions / suggestions:

  • why limit it to assertions on a string literal expression?
    • should probably apply to all literal types
    • numeric literal
    • boolean literals
    • bigint literals
  • check union types:
    • 'foo' as 'foo' | 'bar' -> Ok
    • 'foo' as 'bar' | 'baz' -> Error
    • 'foo' | 'bar' as 'foo' -> Ok
    • 'bar' | 'baz' as 'foo' -> Error
    • 'foo' | 'bar' as 'foo' | 'baz' -> Ok
    • 'foo' | 'bar' as 'baz' | 'bas' -> Error
DanielRosenwasser

comment created time in 3 months

more