Giter Site home page Giter Site logo

ts-spec's People

Contributors

geoffreytools avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ts-spec's Issues

ts-spec no longer works in TS 4.8

The fix in #5 caused a regression in TS 4.8.

In this version, Uppercase<string> | Lowercase<string> | Capitalize<string> | Uncapitalize<string> can't be resolved to anything and any conditional type mentioning them makes the problem bubble up, to the point the entire disambiguation algorithm and the two operands of the comparison ultimately fail to resolve as well.

false positive on unions with `undefined`

import {test} from 'ts-spec'

//Type 'FailingTest<"pass", number, number | undefined>' is not assignable to type 'PassingTest | PassingTest[]'.
test('pass' as const, (t) => t.equal(1 as number | undefined)<number | undefined>())

playground

feature request: assignability

I would like a way to write a test like the following:

interface Foo {
  foo: string | number;
}

test("{ foo: 10 } is assignable to Foo", (t) => t.assignable({ foo: 10 })<Foo>());

This seems to be subtly different to extends and includes in that extends tests that A is a strict superset of B instead of testing that A is sufficient to satisfy B.

Regression in 1.4.3

The follow usage used to work in 1.4.0 and doesn't work in the current release:

class Foo {}
const foo = { foo: Foo } as const;
test("object maps to constructors", (t) => t.equal(foo)<{ readonly foo: new () => Foo }>());

I'm not sure if this is a bug or if I'm misusing the testing library but I can't make this case work out again now.

// It looks like this succeeds:
test("class includes a constructor", (t) => t.includes<Foo, new () => Foo>());
// But both of these fail:
test("class includes a constructor", (t) => t.includes(Foo)<new () => Foo>();
test("object maps to constructors", (t) => t.includes(foo)<{ foo: new () => Foo }>());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.